import {useEffect} from 'react'

const SimulateLife = ()=>{
    // 模拟挂载的生命周期
    const useMount = (callback)=>{
        useEffect(()=>{
            callback()
        },[])
    }
    
    // 模拟卸载的生命周期
    const useUnmount = (callback)=>{
        useEffect(()=>{
            return()=>{
                callback()
            }
        },[])
    }

    useMount(()=>{
        console.log('挂载了');
    })

    useUnmount(()=>{
        console.log('卸载了');
    })
}


export default SimulateLife